/*
 * @Author: gitee 1758024667@qq.com
 * @Date: 2023-01-15 20:44:19
 * @LastEditors: gitee 1758024667@qq.com
 * @LastEditTime: 2023-03-04 15:58:30
 * @FilePath: \parking-lot-management\src\router\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/register',
    component: () => import('@/views/register/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页管理', icon: 'dashboard' }
    }]
  }

  // 404 page must be placed at the end !!!
  // { path: '*', redirect: '/404', hidden: true }
]

// 引入多个模块的规则
// import agentsRouter from './modules/agents'
// import categoriesRouter from './modules/categories'
// import clientsRouter from './modules/clients'
// import pagesRouter from './modules/pages'
// import permissionsRouter from './modules/permissions'
// import rolesRouter from './modules/roles'
import properties from './modules/properties'
// import employeesRouter from './modules/employees'
import my from './modules/my'
import parking from './modules/parking'
import order from './modules/order'
import chart from './modules/rotationChart'
import coupon from './modules/coupon'
import space from './modules/space'
import balance from './modules/balance'

// 动态路由
export const asyncRoutes = [
  // properties,
  parking,
  order,
  chart,
  coupon,
  space,
  balance
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  // 静态路由
  routes: [...constantRoutes, ...asyncRoutes]
  // 动态路由
  // routes: [...constantRoutes]
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
